package com.smart.community.property.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.smart.community.property.entity.FeeRule;
import com.smart.community.property.mapper.FeeRuleMapper;
import com.smart.community.property.service.IFeeRuleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.List;

/**
 * 费用规则服务实现
 * @author Wu.Liang
 * @since 2024-12-21
 */
@Slf4j
@Service
public class FeeRuleServiceImpl extends ServiceImpl<FeeRuleMapper, FeeRule> 
    implements IFeeRuleService {

    @Override
    public FeeRule getLatestRule(Integer feeType, Long communityId) throws Exception {
        return this.baseMapper.selectLatestRule(feeType, communityId, LocalDate.now());
    }

    @Override
    public IPage<FeeRule> getFeeRulePage(Page<FeeRule> page, Integer feeType, Long communityId, Integer status) throws Exception {
        return this.baseMapper.selectFeeRulePage(page, feeType, status, communityId);
    }

    @Override
    public List<FeeRule> getActiveRulesByTypeAndCommunity(Integer feeType, Long communityId, LocalDate date) throws Exception {
        return this.baseMapper.selectActiveRulesByTypeAndCommunity(feeType, communityId);
    }
}
